﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml.Serialization;

namespace ObjectModel.PowerPoint.New
{
    public class LinkedTextRangeCollection : ObservableCollection<LinkedTextRange>
    {
        LinkedTextRange mSelectedItem;

        [XmlIgnore]
        public LinkedTextRange SelectedItem
        {
            get { return mSelectedItem; }

            set
            {
                mSelectedItem = value;

                if (mSelectedItem != null)
                    mSelectedItem.Select();

                OnPropertyChanged(new PropertyChangedEventArgs("SelectedItem"));
            }
        }

        public new void Remove(LinkedTextRange item)
        {
            item.UnhookEvents();
            base.Remove(item);
        }

        public new void RemoveAt(int index)
        {
            base[index].UnhookEvents();
            base.RemoveAt(index);
        }
    }
}
